3.14 \(\int \frac{\sec ^2(x)}{a+b \csc (x)} \, dx\)

Optimal. Leaf size=65 \[ \frac{2 a b \tanh ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2} \]

[Out]

(2*a*b*ArcTanh[(a + b*Tan[x/2])/Sqrt[a^2 - b^2]])/(a^2 - b^2)^(3/2) - (Sec[x]*(b - a*Sin[x]))/(a^2 - b^2)

________________________________________________________________________________________

Rubi [A]  time = 0.135217, antiderivative size = 65, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.462, Rules used = {3872, 2866, 12, 2660, 618, 206} \[ \frac{2 a b \tanh ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2} \]

Antiderivative was successfully verified.

[In]

Int[Sec[x]^2/(a + b*Csc[x]),x]

[Out]

(2*a*b*ArcTanh[(a + b*Tan[x/2])/Sqrt[a^2 - b^2]])/(a^2 - b^2)^(3/2) - (Sec[x]*(b - a*Sin[x]))/(a^2 - b^2)

Rule 3872

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_.)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_.), x_Symbol] :> Int[((g*C
os[e + f*x])^p*(b + a*Sin[e + f*x])^m)/Sin[e + f*x]^m, x] /; FreeQ[{a, b, e, f, g, p}, x] && IntegerQ[m]

Rule 2866

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*sin[(e_.)
 + (f_.)*(x_)]), x_Symbol] :> Simp[((g*Cos[e + f*x])^(p + 1)*(a + b*Sin[e + f*x])^(m + 1)*(b*c - a*d - (a*c -
b*d)*Sin[e + f*x]))/(f*g*(a^2 - b^2)*(p + 1)), x] + Dist[1/(g^2*(a^2 - b^2)*(p + 1)), Int[(g*Cos[e + f*x])^(p
+ 2)*(a + b*Sin[e + f*x])^m*Simp[c*(a^2*(p + 2) - b^2*(m + p + 2)) + a*b*d*m + b*(a*c - b*d)*(m + p + 3)*Sin[e
 + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, g, m}, x] && NeQ[a^2 - b^2, 0] && LtQ[p, -1] && IntegerQ[2*m]

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{\sec ^2(x)}{a+b \csc (x)} \, dx &=\int \frac{\sec (x) \tan (x)}{b+a \sin (x)} \, dx\\ &=-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac{\int \frac{a b}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac{(a b) \int \frac{1}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac{(2 a b) \operatorname{Subst}\left (\int \frac{1}{b+2 a x+b x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{a^2-b^2}\\ &=-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2}+\frac{(4 a b) \operatorname{Subst}\left (\int \frac{1}{4 \left (a^2-b^2\right )-x^2} \, dx,x,2 a+2 b \tan \left (\frac{x}{2}\right )\right )}{a^2-b^2}\\ &=\frac{2 a b \tanh ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac{\sec (x) (b-a \sin (x))}{a^2-b^2}\\ \end{align*}

Mathematica [A]  time = 0.306233, size = 97, normalized size = 1.49 \[ \frac{2 a b \tan ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{b^2-a^2}}\right )}{\left (b^2-a^2\right )^{3/2}}+\sin \left (\frac{x}{2}\right ) \left (\frac{1}{(a-b) \left (\sin \left (\frac{x}{2}\right )+\cos \left (\frac{x}{2}\right )\right )}+\frac{1}{(a+b) \left (\cos \left (\frac{x}{2}\right )-\sin \left (\frac{x}{2}\right )\right )}\right ) \]

Antiderivative was successfully verified.

[In]

Integrate[Sec[x]^2/(a + b*Csc[x]),x]

[Out]

(2*a*b*ArcTan[(a + b*Tan[x/2])/Sqrt[-a^2 + b^2]])/(-a^2 + b^2)^(3/2) + Sin[x/2]*(1/((a + b)*(Cos[x/2] - Sin[x/
2])) + 1/((a - b)*(Cos[x/2] + Sin[x/2])))

________________________________________________________________________________________

Maple [A]  time = 0.056, size = 92, normalized size = 1.4 \begin{align*} -4\,{\frac{1}{ \left ( 4\,a+4\,b \right ) \left ( \tan \left ( x/2 \right ) -1 \right ) }}-4\,{\frac{1}{ \left ( 4\,a-4\,b \right ) \left ( \tan \left ( x/2 \right ) +1 \right ) }}-2\,{\frac{ab}{ \left ( a+b \right ) \left ( a-b \right ) \sqrt{-{a}^{2}+{b}^{2}}}\arctan \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) +2\,a}{\sqrt{-{a}^{2}+{b}^{2}}}} \right ) } \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sec(x)^2/(a+b*csc(x)),x)

[Out]

-4/(4*a+4*b)/(tan(1/2*x)-1)-4/(4*a-4*b)/(tan(1/2*x)+1)-2*a*b/(a+b)/(a-b)/(-a^2+b^2)^(1/2)*arctan(1/2*(2*b*tan(
1/2*x)+2*a)/(-a^2+b^2)^(1/2))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 0.51696, size = 576, normalized size = 8.86 \begin{align*} \left [-\frac{\sqrt{a^{2} - b^{2}} a b \cos \left (x\right ) \log \left (-\frac{{\left (a^{2} - 2 \, b^{2}\right )} \cos \left (x\right )^{2} + 2 \, a b \sin \left (x\right ) + a^{2} + b^{2} - 2 \,{\left (b \cos \left (x\right ) \sin \left (x\right ) + a \cos \left (x\right )\right )} \sqrt{a^{2} - b^{2}}}{a^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \, a^{2} b - 2 \, b^{3} - 2 \,{\left (a^{3} - a b^{2}\right )} \sin \left (x\right )}{2 \,{\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \left (x\right )}, \frac{\sqrt{-a^{2} + b^{2}} a b \arctan \left (-\frac{\sqrt{-a^{2} + b^{2}}{\left (b \sin \left (x\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \cos \left (x\right )}\right ) \cos \left (x\right ) - a^{2} b + b^{3} +{\left (a^{3} - a b^{2}\right )} \sin \left (x\right )}{{\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \left (x\right )}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="fricas")

[Out]

[-1/2*(sqrt(a^2 - b^2)*a*b*cos(x)*log(-((a^2 - 2*b^2)*cos(x)^2 + 2*a*b*sin(x) + a^2 + b^2 - 2*(b*cos(x)*sin(x)
 + a*cos(x))*sqrt(a^2 - b^2))/(a^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2)) + 2*a^2*b - 2*b^3 - 2*(a^3 - a*b^2)*s
in(x))/((a^4 - 2*a^2*b^2 + b^4)*cos(x)), (sqrt(-a^2 + b^2)*a*b*arctan(-sqrt(-a^2 + b^2)*(b*sin(x) + a)/((a^2 -
 b^2)*cos(x)))*cos(x) - a^2*b + b^3 + (a^3 - a*b^2)*sin(x))/((a^4 - 2*a^2*b^2 + b^4)*cos(x))]

________________________________________________________________________________________

Sympy [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\sec ^{2}{\left (x \right )}}{a + b \csc{\left (x \right )}}\, dx \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)**2/(a+b*csc(x)),x)

[Out]

Integral(sec(x)**2/(a + b*csc(x)), x)

________________________________________________________________________________________

Giac [A]  time = 1.41589, size = 128, normalized size = 1.97 \begin{align*} -\frac{2 \,{\left (\pi \left \lfloor \frac{x}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (b\right ) + \arctan \left (\frac{b \tan \left (\frac{1}{2} \, x\right ) + a}{\sqrt{-a^{2} + b^{2}}}\right )\right )} a b}{{\left (a^{2} - b^{2}\right )} \sqrt{-a^{2} + b^{2}}} - \frac{2 \,{\left (a \tan \left (\frac{1}{2} \, x\right ) - b\right )}}{{\left (a^{2} - b^{2}\right )}{\left (\tan \left (\frac{1}{2} \, x\right )^{2} - 1\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="giac")

[Out]

-2*(pi*floor(1/2*x/pi + 1/2)*sgn(b) + arctan((b*tan(1/2*x) + a)/sqrt(-a^2 + b^2)))*a*b/((a^2 - b^2)*sqrt(-a^2
+ b^2)) - 2*(a*tan(1/2*x) - b)/((a^2 - b^2)*(tan(1/2*x)^2 - 1))